package com.prs.crm.action.project.frost;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;

import com.prs.crm.annotation.Clew;
import com.prs.crm.context.AppContext;
import com.prs.crm.domain.project.Project;
import com.prs.crm.service.project.ProjectService;

public class ForstProjectAction extends BaseAction{
	
	private static final long serialVersionUID = 1L;

	private ProjectService projectService;
	
	private PaginationSupport pagination;
	
	private Project project;

	public void setProjectService(ProjectService projectService) {
		this.projectService = projectService;
	}

	public ProjectService getProjectService() {
		return projectService;
	}

	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}

	public PaginationSupport getPagination() {
		return pagination;
	}

	public void setProject(Project project) {
		this.project = project;
	}

	public Project getProject() {
		return project;
	}
	
	@Action("listMyProject")
	public String listProject()
	{
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getProjectService().listCreateProject( pagination,
				AppContext.getAccountContext().currentUser()));
		return SUCCESS;
	}
	
	@Action("projectDetail")
	public String projectDetail()
	{
		return SUCCESS;
	}
	
	@Action("frostProjectDetail")
	public String frostProjectDetail()
	{
		return SUCCESS;
	}
	
	@Action("prepareFrostProject")
	public String prepareFrostProject()
	{

		return SUCCESS;
	}
	
	@Action("listFrostProject")
	public String listFrostProject()
	{
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getProjectService().listFrostProject( pagination,
				AppContext.getAccountContext().currentUser()));
		return SUCCESS;
	}
	
	
	@Clew(results={"success"})
	@Action(value="executeFrostProject",results={@Result(name="success",type="redirect",location="listMyProject")})
	public String executeFrostProject()
	{
		this.getProjectService().executeFrostProject(project);
		this.setPrompt("项目已被成功冻结");
		return SUCCESS;
	}
	
	@Action("listUnFrostProject")
	public String listUnFrostProject()
	{
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getProjectService().listFrostProject( pagination,
				AppContext.getAccountContext().currentUser()));
		return SUCCESS;
	}
	
	@Action("unFrostProjectDetail")
	public String unFrostProjectDetail()
	{
		return SUCCESS;
	}
	
	@Clew(results={"success"})
	@Action(value="unFreezeProject",results={@Result(name="success",type="redirect",location="listUnFrostProject")})
	public  String unFreezeProject()
	{	
		this.getProjectService().executeUnfreezeProject(project);
		this.setPrompt("项目已被成功解冻");
		return SUCCESS;	
	}
	
}
